package gui;

import javax.swing.*;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.io.IOException;

@SuppressWarnings("serial")
public class LayeredPane extends JPanel {
	
	private JLayeredPane layeredPane;
	protected GroundDrawer gd;
	private RockDrawer rd;
	protected BallDrawer bd;
	
	public RockDrawer getRockLayer(){
		return rd;
	}
	
	public LayeredPane() {
		gd = new GroundDrawer(new Dimension(30, 20));
		rd = new RockDrawer(new Dimension(30, 20));
		bd = new BallDrawer(new Dimension(30, 20));
		
		layeredPane = new JLayeredPane();
		layeredPane.setPreferredSize(gd.getSize());
		layeredPane.add(rd, 0);
		layeredPane.add(bd, 1);
		layeredPane.add(gd, 2);

		add(layeredPane);
	}
	
	public static void main(String[] args) {
		MapViewPort mvp = new MapViewPort(new PlayersMap());
		
		JComponent newContentPane = mvp;
		
		newContentPane.setOpaque(false);
		
		try {
			new MainWindow("settings.dat");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (AWTException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		MainWindow.getMainWindow().setCenter();
		JFrame jf = new JFrame ("Amgine");
		newContentPane.setPreferredSize(new Dimension(800, 600)); // 640x480
		jf.setContentPane(newContentPane);
		jf.pack();
		jf.setLocationRelativeTo(null);
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try {
			Robot r = new Robot();
			r.mouseMove(MainWindow.getCenterX(), MainWindow.getCenterY());
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}
}